package xuegao.study.mall.web.component;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import xuegao.study.mall.web.service.PortalOrderService;

/**
 * 取消订单消息的接收者
 */
@Component
@RabbitListener(queues = "mall.order.cancel")
public class CancelOrderReceiver {

    private Logger logger = LoggerFactory.getLogger(CancelOrderReceiver.class);

    @Autowired
    private PortalOrderService portalOrderService;

    @RabbitHandler
    public void handle(Long orderId) {
        portalOrderService.cancelOrder(orderId);
        logger.info("process orderId:{}", orderId);
    }

}
